import { getToken, setToken, removeToken } from '@/utils/auth'
const state ={
  roles:[],
  token:''
}
const mutations={
  setToken(state,data){
    state.token=data
  },
  setRoles(state,data){
    state.roles=data
  }
}
const actions={
  async getInfo({commit,dispatch,getters,rootGetters,rootState,state}){
    commit('setRoles', [1,2,3])
    return {
      roles:[1,2,3],
    }
  },
  resetToken({ commit }) {
    return new Promise(resolve => {
      commit('setToken', '')
      commit('setRoles', [])
      removeToken()
      resolve()
    })
  },
}
const getters={
  roles: state => state.roles,
}
export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}